function $(id){
    return typeof id==='string'? document.getElementById(id):id;
}
/*
window.onload=function(){
    var titles=$('notice-tit').getElementsByTagName('li'),
		condivs=$('notice-con').getElementsByTagName('div');
    if(titles.length!=condivs.length){
        return ;
    }
    for(var i=0;i<titles.length;i++){
        titles[i].id=i;
		titles[i].onmouseover=function(){
			for(var j=0;j<titles.length;j++){
				titles[j].className='';
				condivs[j].style.display='none';
			}
			this.className='select';
			condivs[this.id].style.display='block';
		}
    }
}
*/
//定时器的效果
/*
window.onload=function(){
	var index=0;
	var timer=null;
    var titles=$('notice-tit').getElementsByTagName('li'),
		condivs=$('notice-con').getElementsByTagName('div');
    if(titles.length!=condivs.length){
        return ;
    }
    for(var i=0;i<titles.length;i++){
        titles[i].id=i;
		titles[i].onmouseover=function(){
			var that=this;
			if(timer){
				clearTimeout(timer);
				timer=null;
			}
			timer=setTimeout(function(){
			
			for(var j=0;j<titles.length;j++){
				titles[j].className='';
				condivs[j].style.display='none';
			}
			titles[that.id].className='select';
			condivs[that.id].style.display='block';
			},500);
			
		}
    }
}*/

window.onload=tab;
function tab(){
	var index=0;//当前高亮页签索引
	var timer=null;
	var titles=$('notice-tit').getElementsByTagName('li');
	var content=$('notice-con').getElementsByTagName('div');
	//鼠标滑过切换,划出又恢复定时器
	for(var j=0;j<titles.length;j++){
		titles[j].id=j;
		titles[j].onmouseover=function(){
			clearInterval(timer);
			changeobj(this.id);
		}
		titles[j].onmouseout=function(){
		timer=setInterval(autoplay,2000);
		}
	}
	if(timer){
				clearTimeout(timer);
				timer=null;
			}
	//定时器
	timer=setInterval(autoplay,2000);
	//重复函数
	//自动播放
	function autoplay(){
		timer=setInterval(function(){
		index++;
		if(index>=titles.length){
			index=0;
		}
		changeobj(index);
	});
	}
	//样式改变
	function changeobj(curindex){
		for(var i=0;i<titles.length;i++){
			titles[i].className='';
			content[i].style.display='none';
		}
		titles[curindex].className='select';
		content[curindex].style.display='block';
		index=curindex;
	}
	
}